import { create } from 'zustand';
import type { UploadFile } from 'antd/es/upload/interface';

interface AnalysisResult {
  html?: string;
  markdown?: string;
  previewImage?: string;
  theme?: string;
  uploadedFileList?: UploadFile[];
  hasUploadedFile?: boolean;
  streamHtml?: string;
}

interface AnalysisStore {
  analysisResult: AnalysisResult;
  setAnalysisResult: (result: AnalysisResult) => void;
  clearAnalysisResult: () => void;
}

export const useAnalysisStore = create<AnalysisStore>((set) => ({
  analysisResult: {
    html:"",//html字段
    markdown:"",//markdown字段
    previewImage:"",//预览图片字段
    theme:"modern",//主题字段
    uploadedFileList:[],//上传的文件列表字段
    hasUploadedFile:false,//是否上传文件字段
    streamHtml:"",//流式生成的HTML内容
  },
  setAnalysisResult: (result) => set((state) => ({
    analysisResult: { ...state.analysisResult, ...result }
  })),
  clearAnalysisResult: () => set({ analysisResult: {
    html:"",
    markdown:"",
    previewImage:"",
    theme:"modern",
    uploadedFileList:[],
    hasUploadedFile:false,
    streamHtml:"",
  } }),
})); 